﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            //Mapper.Initialize(cfg =>
            //{
            //    cfg.AddMemberConfiguration();

            //    cfg.CreateMissingTypeMaps = true;

            //    cfg.CreateMap<Dto, Entity>();

            //    cfg.CreateMap<Comment, EntityComment>()
            //       .ForMember(dest => dest.Comment, opt => opt.MapFrom(src => src.AuditComment));

            //});
           
            var dto = new Dto()
            {
                Id = 5,
                Name = "9999",
                Comments = new List<Comment>() { new Comment { Id = 3, AuditComment = "Pass" } }
            };
            Console.WriteLine(dto.GetHashCode());
            var dto2 = new Dto()
            {
                Id = 5,
                Name = "Wilson2",
                Comments = new List<Comment>() { new Comment { Id = 3, AuditComment = "Pass" } }
            };
            var dto3 = dto2.M();
            //Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(Mapper.Map<List<EntityComment>>(dto.Comments)));
        }
    }

    class DemoProfile : Profile
    {
        public DemoProfile()
        {
            this.CreateMap<Entity, Dto>();

        }
    }

    class Entity
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

    class EntityComment
    {
        public int Id { get; set; }
        public string Comment { get; set; }
    }



    public class Dto
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public List<Comment> Comments { get; set; }

        public Dto M()
        {
            return this.MemberwiseClone() as Dto;
        }
    }

    public class Comment
    {
        public int Id { get; set; }
        public string AuditComment { get; set; }
    }
}
